import {
	WFDynaActionViewActionType,
	IWFDynaActionViewAbility,
	IWFDynaActionViewControllerParams,
	IWFDynaActionViewModel,
	IWFDynaActionViewStore,
	IParam,
	IViewEvent,
} from '@/core';
import { QXEvent } from 'qx-util';
import {
	getViewClassNames,
	useViewAction,
	useViewBasic,
	useViewControllerParams,
	useViewProps,
} from '../use-view';

/**
 * 获取工作流动态选项操作视图输入参数
 *
 * @export
 * @return {*}
 */
export function useWFDynaActionViewProps() {
	return {
		...useViewProps(),
	};
}

/**
 * 获取工作流动态选项操作视图基础
 *
 * @export
 * @param {IWFDynaActionViewModel} model 工作流动态选项操作视图模型
 * @param {IParam} props 输入参数
 * @return {*}
 */
export function useWFDynaActionViewBasic(
	model: IWFDynaActionViewModel,
	props: IParam
) {
	const getClassNames = (props: IParam) => {
		return getViewClassNames(model, props);
	};
	return {
		...useViewBasic(model, props),
		getClassNames,
	};
}

/**
 * 工作流动态选项操作视图行为
 *
 * @export
 */
export function useWFDynaActionViewAction(controller: any) {
	const handleConfirm = () => {
		controller.confirm();
	};
	const handleCancel = () => {
		controller.cancel();
	};
	return {
		...useViewAction(controller),
		handleConfirm,
		handleCancel,
	};
}

/**
 * 获取工作流动态选项操作视图控制器输入参数
 *
 * @export
 * @param {IWFDynaActionViewModel} model
 * @param {IParam} props
 * @param {QXEvent<IViewEvent<WFDynaActionViewActionType, IWFDynaActionViewAbility>>} evt
 * @return {*}  {IWFDynaActionViewControllerParams<WFDynaActionViewActionType, IWFDynaActionViewAbility>}
 */
export function useWFDynaActionViewControllerParams(
	model: IWFDynaActionViewModel,
	props: IParam,
	evt: QXEvent<IViewEvent<WFDynaActionViewActionType, IWFDynaActionViewAbility>>
): IWFDynaActionViewControllerParams<
	WFDynaActionViewActionType,
	IWFDynaActionViewAbility
> {
	return {
		...useViewControllerParams<IWFDynaActionViewStore, IWFDynaActionViewModel>(
			model,
			props,
			evt
		),
	};
}
